-
-
Notifications
You must be signed in to change notification settings - Fork 4
Make fwdata api respect nullable return types #2048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make fwdata api respect nullable return types #2048
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThis PR addresses issue #2047 by modifying FwDataMiniLcmApi to return null instead of throwing when entities are not found. GetEntry, GetSense, and GetExampleSentence now use TryGetObject for safe retrieval. Comprehensive test coverage is added across MiniLcm base classes and multiple implementations to verify null-returning behavior for missing entities. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes The core API changes are straightforward but affect critical read methods with nullable return types. Multiple test classes and implementations are added with consistent patterns across heterogeneous contexts. The spread across multiple files and the importance of null-handling correctness for sync operations warrant careful review. Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The latest updates on your projects. Learn more about Argos notifications ↗︎ Awaiting the start of a new Argos build… |
UI unit Tests 1 files 45 suites 27s ⏱️ Results for commit a7b85b1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
backend/FwLite/FwLiteProjectSync.Tests/CrdtRepairTests.cs (2)
217-234
: Clarify the assertion message on line 229.The assertion message states "the crdt translation was removed", but the test actually removes the entire example sentence (line 227), not just a translation. The message should reflect that an example sentence was removed, which cascades to remove its translations.
Apply this diff to clarify the message:
- result.CrdtChanges.Should().Be(1, "the crdt translation was removed"); + result.CrdtChanges.Should().Be(1, "the crdt example sentence was removed");
277-293
: Capture sync result for consistency.Unlike the similar test at lines 217-234 and the pattern established at line 210, this test doesn't capture the sync result or verify the
CrdtChanges
count. For consistency and more complete test coverage, consider capturing the result and asserting the expected change count.Apply this diff to add the assertion:
// act await CrdtApi.DeleteExampleSentence(entryId, senseId, exampleSentenceId); - await SyncService.Sync(CrdtApi, FwDataApi); + var result = await SyncService.Sync(CrdtApi, FwDataApi); + result.CrdtChanges.Should().Be(0, "no crdt changes expected when deleting from crdt side"); // assert - the fw translation was also removedbackend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs (1)
9-9
: Consider makingappleId
static readonly.For consistency with
SenseTestsBase
(line 5-6 in backend/FwLite/MiniLcm.Tests/SenseTestsBase.cs) and since the ID is only used for test setup, consider making this fieldstatic readonly
.Apply this diff:
- private readonly Guid appleId = Guid.NewGuid(); + private static readonly Guid appleId = Guid.NewGuid();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/SenseTests.cs
(1 hunks)backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
(3 hunks)backend/FwLite/FwLiteProjectSync.Tests/CrdtRepairTests.cs
(2 hunks)backend/FwLite/LcmCrdt.Tests/MiniLcmTests/SenseTests.cs
(1 hunks)backend/FwLite/MiniLcm.Tests/ExampleSentenceTestsBase.cs
(2 hunks)backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs
(3 hunks)backend/FwLite/MiniLcm.Tests/SenseTestsBase.cs
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
backend/FwLite/LcmCrdt.Tests/MiniLcmTests/SenseTests.cs (2)
backend/FwLite/MiniLcm.Tests/SenseTestsBase.cs (2)
SenseTestsBase
(3-37)Task
(8-21)backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/SenseTests.cs (1)
Task
(8-11)
backend/FwLite/MiniLcm.Tests/ExampleSentenceTestsBase.cs (3)
backend/FwLite/MiniLcm/Models/ExampleSentence.cs (1)
Guid
(20-23)backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs (2)
Sense
(764-779)RichString
(860-870)backend/FwLite/MiniLcm/Models/RichString.cs (2)
RichString
(11-13)RichString
(87-90)
backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/SenseTests.cs (2)
backend/FwLite/LcmCrdt.Tests/MiniLcmTests/SenseTests.cs (3)
SenseTests
(3-19)Task
(7-12)Task
(14-18)backend/FwLite/MiniLcm.Tests/SenseTestsBase.cs (2)
SenseTestsBase
(3-37)Task
(8-21)
backend/FwLite/MiniLcm.Tests/SenseTestsBase.cs (2)
backend/FwLite/MiniLcm.Tests/MiniLcmTestBase.cs (1)
MiniLcmTestBase
(7-31)backend/FwLite/MiniLcm.Tests/ExampleSentenceTestsBase.cs (1)
Task
(9-30)
backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs (2)
backend/FwLite/MiniLcm.Tests/ExampleSentenceTestsBase.cs (7)
Fact
(32-37)Fact
(39-45)Fact
(47-59)Fact
(61-70)Fact
(72-98)Fact
(100-129)Fact
(131-156)backend/FwLite/LcmCrdt/Data/MiniLcmRepository.cs (10)
Task
(26-29)Task
(95-103)Task
(105-112)Task
(114-118)Task
(120-125)Task
(157-195)Task
(215-233)Task
(235-241)Task
(243-249)Task
(251-256)
backend/FwLite/FwLiteProjectSync.Tests/CrdtRepairTests.cs (1)
backend/FwLite/MiniLcm.Tests/ExampleSentenceTestsBase.cs (8)
Fact
(32-37)Fact
(39-45)Fact
(47-59)Fact
(61-70)Fact
(72-98)Fact
(100-129)Fact
(131-156)Task
(9-30)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Build FwHeadless / publish-fw-headless
- GitHub Check: Analyze (csharp)
- GitHub Check: Build FW Lite and run tests
- GitHub Check: frontend-component-unit-tests
- GitHub Check: frontend
🔇 Additional comments (10)
backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs (1)
956-957
: LGTM! Correctly implements null-returning behavior for missing entities.The changes to
GetEntry
,GetSense
, andGetExampleSentence
properly useTryGetObject
instead ofGetObject
, ensuring these methods return null when entities are not found rather than throwing exceptions. This aligns with the PR objectives and the methods' nullable return types.Also applies to: 1427-1428, 1554-1555
backend/FwLite/MiniLcm.Tests/ExampleSentenceTestsBase.cs (1)
7-7
: LGTM! Comprehensive test coverage for null-returning behavior.The test additions effectively verify that
GetExampleSentence
returns null for missing entities and returns the correct data for existing ones. The setup inInitializeAsync
creates a known example sentence to support the positive test case.Also applies to: 18-27, 32-45
backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs (3)
27-31
: LGTM!Good modification to use a predefined ID for the Apple entry, enabling the new test to verify retrieval by ID.
100-105
: LGTM!The test correctly verifies that GetEntry returns null for a non-existent entry, directly addressing the PR objective.
107-113
: LGTM!The test correctly verifies that GetEntry returns the expected entry and validates its content.
backend/FwLite/LcmCrdt.Tests/MiniLcmTests/SenseTests.cs (1)
1-19
: LGTM!The test class correctly implements the fixture pattern for running
SenseTestsBase
tests against the LcmCrdt implementation. The async lifecycle management is properly handled.backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/SenseTests.cs (1)
1-12
: LGTM!The test class correctly uses the xUnit collection fixture pattern to run
SenseTestsBase
tests against the FwData implementation. This is crucial for verifying that the FwData API now returns null instead of throwing when entities are not found.backend/FwLite/MiniLcm.Tests/SenseTestsBase.cs (3)
8-21
: LGTM!The initialization correctly sets up test data with predefined IDs, enabling predictable testing of sense retrieval behavior across multiple implementations.
23-28
: LGTM!The test correctly verifies that GetSense returns null for a non-existent sense, directly addressing the PR objective to return null instead of throwing.
30-36
: LGTM!The test correctly verifies that GetSense returns the expected sense and validates its content.
a7b85b1
to
2a5ba8a
Compare
Resolves #2047